import QtQuick 1.0

Rectangle {
    id: progressBar
    property real minValue:0
    property real maxValue:100
    property real value: 0
    property alias progressColor: progress.color
    width: 100
    height: 62
    color: "white"

    function progressWidth() {
        if (progressBar.maxValue == progressBar.minValue) {
            return progressBar.width
        }

        progressBar.value = Math.max(progressBar.minValue, progressBar.value)
        progressBar.value = Math.min(progressBar.maxValue, progressBar.value)
        return progressBar.width*progressBar.value/(progressBar.maxValue-progressBar.minValue)
    }

    Rectangle {
        id: progress
        color: "royalblue"
        anchors.left: parent.left
        anchors.top: parent.top
        anchors.bottom: parent.bottom
        width: progressWidth()
    }
}
